package com.group.hugedatabehind.controller;

import com.group.hugedatabehind.pojo.Message;
import com.group.hugedatabehind.service.NameService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/message")
@CrossOrigin(origins = "*") // 允许所有来源的请求
public class NameController {

    @Autowired
    private NameService nameService;

    @PostMapping("/name")
    public Message getMessage(@RequestBody NameRequest nameRequest) {
        return nameService.getMessageBySenderName(nameRequest.getSname());
    }
}

class NameRequest {
    private String sname;

    public String getSname() {
        return sname;
    }

    public void setSname(String sname) {
        this.sname = sname;
    }
}
